package com.ax.center.controller;

import com.ax.center.annotation.Logging;
import com.ax.center.dto.ApiResponse;
import com.ax.center.entity.Authority;
import com.ax.center.service.AuthorityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zy
 * @date 2023/7/4 16:32
 */
@RestController
@RequestMapping(value = "authorityController")
@Api(tags = "权限服务")
@CrossOrigin(origins = "http://localhost:5173")
public class AuthorityController {

    @Autowired
    private AuthorityService authorityService;

    @PostMapping("/无效的请求")
    public void test(@RequestBody Authority authority){
        return;
    }

   @GetMapping("/queryAll1")
   @Logging(description = "查询所有权限id")
    @ApiOperation("查询所有权限id")
    public ApiResponse queryAll(){
        return  authorityService.queryAllAuthId();
   }

    @GetMapping("/queryAll2")
    @Logging(description = "查询所有权限信息")
    @ApiOperation("查询所有权限信息")
    public ApiResponse queryAll2(){
        return  authorityService.queryAllAuthInfo();
    }


    @GetMapping("/deleteById/{id}")
    @Logging(description = "删除一条权限")
    @ApiOperation("删除一条权限")
    public ApiResponse deleteById(@PathVariable("id")Long id){
        return  authorityService.deleteById(id);
    }

    @GetMapping(value = "/queryByPre")
    @Logging(description = "根据前缀查询权限")
    @ApiOperation("根据前缀查询权限")
    public ApiResponse queryByPre(){
        return authorityService.queryByPre();
    }
}
